<template>
	<view>
		<view class="pmain">
			<view class="item">
				<text class="price">价格</text>
				<text class="num">数量</text>
			</view>

			<view class="item uni-down" v-for="(item,index) in saleList_">
				<text class="price">{{item.price}}</text>
				<text class="num">{{item.num}}</text>
				<view class="bg buybg" :style="[{ width:item.num+'%'}]"></view>
			</view>

			<view>
				<view class="row margin-right">
					{{now}}
				</view>
				<view class="row text-gray text-xs">
					≈{{now*7}} CNY
				</view>
			</view>

			<view class="item uni-up" v-for="(item,index) in buyList_">
				<text class="price">{{item.price}}</text>
				<text class="num">{{item.num}}</text>
				<view class="bg sellbg" style="width: 50%;"></view>
			</view>

			<view class="depth uni-thinner-border" @click="depthClick">
				<view class="uni-h6">深度{{depthValue}}</view>
				<view class="popover-wrap" v-show="popoverVisible">
					<view class="kailong"></view>
					<view class="popover uni-thinner-border">
						<view class="item uni-divider" @click="depthChange(1)">1</view>
						<view class="item uni-divider" @click="depthChange(2)">2</view>
						<view class="item uni-divider" @click="depthChange(3)">3</view>
						<view class="item uni-divider" @click="depthChange(4)">4</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			saleList: {
				type: Array,
				default: () => {
					return []
				}
			},
			buyList: {
				type: Array,
				default: () => {
					return []
				}
			}
		},
		data() {
			return {
				popoverVisible: false,
				depthValue: 1
			}
		},
		computed: {
			saleList_() {
				return this.saleList;
			},
			buyList_() {
				return this.buyList;
			},
			now(){
				return this.buyList[0] ? this.buyList[0].price : '';
			}
		},
		methods: {
			depthClick(e) {
				this.popoverVisible = !this.popoverVisible;
			},
			depthChange(e) {
				this.depthValue = e;
				this.$emit('depthChange', e);
			}
		}
	}
</script>

<style scoped>
	.pmain {
		width: 100%;
		height: 600upx;
		position: relative;
		justify-content: space-between;
		text-align: left;
	}

	.pmain .item {
		position: relative;
		width: 100%;
		display: flex;
		font-size: 24upx;
	}

	.pmain .item .bg {
		height: 100%;
		position: absolute;
		top: 0;
		right: 0;
		/* z-index: -9999; */
	}

	.buybg {
		background: rgba(222, 2, 3, 0.1);
		max-width: 100%;
	}

	.sellbg {
		background: rgba(2, 222, 3, 0.1);
	}

	.pmain .item .price {
		display: block;
		width: 50%;
		text-align: left;
	}

	.position .item .num {
		display: block;
		width: 50%;
		text-align: right;
		padding-right: 10upx;
	}

	.pmain .current-price {
		margin: 10upx 0;
	}

	.pmain .current-price .usdt {}

	.pmain .depth {
		position: relative;
		margin-top: 10upx;
		margin-right: 10upx;
	}

	.pmain .depth .uni-h6 {
		text-align: center;
		height: 60upx;
		line-height: 60upx;
	}

	.pmain .depth .popover {
		position: absolute;
		top: 80upx;
		width: 100%;
		z-index: 9999999999;
		background: #ffffff;
		display: inline-block;
		border-radius: 20px;
	}

	.pmain .depth .popover .item {
		width: 100%;
		height: 60upx;
		line-height: 60upx;
		display: block;
		text-align: center;
	}

	.pmain .depth .kailong {
		position: absolute;
		left: 50%;
		top: 74upx;
		transform: translate(-50%, -50%);
		max-width: 50%;
		width: 0;
		height: 0;
		border-right: 20px solid transparent;
		border-left: 20px solid transparent;
		border-bottom: 20px solid #E0E0E0;
	}

	.popover-wrap .uni-thinner-border:before {
		border-radius: 15px !important;
	}

	.row {
		display: inline;
	}
</style>
